'''
# @Title:
# @Time : 2022/3/22 11:12
# @File : Genson_Demo.py
# @Software: PyCharm

'''
from genson import SchemaBuilder


builder = SchemaBuilder()

builder.add_object(
 {
    "category_list":{
        "can_creat_category":True,
        "total_num" :199,
        "categories": [
            {
                "goods_name":"商品1",
                "price":11,
                "sale_num":100,
                "description":"描述1",
            },
            {
                "goods_name": "商品2",
                "price": 22,
                "sale_num": 200,
                "description": "描述2",
            },
            {
                "goods_name": "商品3",
                "price": 33,
                "sale_num": 300,
                "description": "描述3",
            }
        ]
    }
}
)
# 转换为schema
print(builder.to_schema())
# 转换为schema并生成json格式的数据
print(builder.to_json(indent=2))















